
void counting_sort(int* L, int N, int K){
	int* C = new int[K + 1];

	for (int i = 0; i <= K; i++)
		C[i] = 0;

	for (int i = 0; i < N; i++)
		C[L[i]] = C[L[i]] + 1;

	for (int i = 1; i <= K; i++)
		C[i] = C[i] + C[i - 1];

	int *aux = new int[N];
	for (int i = N - 1; i >= 0; i--){
		C[L[i]] = C[L[i]] - 1;
		aux[C[L[i]]] = L[i];
	}

	for (int i = 0; i < N; i++)
		L[i] = aux[i];
}